// TelnetOptionCollection.cpp: implementation of the CTelnetOptionCollection class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "AnsiTerminal.h"
#include "TelnetOptionCollection.h"
#include "TelnetConstsDef.h"

#include "TelnetLayer.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

// const char TERMINAL_TYPE = char(24);
// const char NAWS = char(31);
// const char LINEMODE = char(34);
// const char ECHO = char(1);
// const char TRANSMIT_BINARY = char(0);
// const char SUPPRESS_GO_AHEAD = char(3);
// const char STATUS = char(5);
// const char TIMING_MARK = char(6);
// const char EXTENDED_OPTIONS_LIST = char(255);
// const char UNKNOWN_OPTION = char(0);
// const char TERMINAL_SPEED = char(32);

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTelnetOptionCollection::CTelnetOptionCollection(CTelnetLayer *pTelnetLayer) :
terminalTypeOption(pTelnetLayer, this),
windowSizeOption(pTelnetLayer, this),
lineModeOption(pTelnetLayer, this),
echoOption(pTelnetLayer, this),
transmitBinaryOption(pTelnetLayer, this),
supressGoAheadOption(pTelnetLayer, this),
statusOption(pTelnetLayer, this),
timingMarkOption(pTelnetLayer, this),
exoplOption(pTelnetLayer, this),
unknownOption(pTelnetLayer, this),
terminalSpeedOption(pTelnetLayer, this)
{
	m_pTelnetLayer = pTelnetLayer;
}

CTelnetOptionCollection::~CTelnetOptionCollection()
{

}

CTelnetOption* CTelnetOptionCollection::FindOption(const char optionType)
{
	switch(optionType)
	{
	case TERMINAL_TYPE:
		return &terminalTypeOption;
	case NAWS:
		return &windowSizeOption;
	case LINEMODE:
		return &lineModeOption;
	case ECHO:
		return &echoOption;
	case TRANSMIT_BINARY:
		return &transmitBinaryOption;
	case SUPPRESS_GO_AHEAD:
		return &supressGoAheadOption;
	case STATUS:
		return &statusOption;
	case TIMING_MARK:
		return &timingMarkOption;
	case EXTENDED_OPTIONS_LIST:
		return &exoplOption;
	case TERMINAL_SPEED:
		return &terminalSpeedOption;
	default:
		afxDump << "@@@ Unknown Option: " << (BYTE)optionType << "\n";
		return &unknownOption;
	}
}

void CTelnetOptionCollection::OnOptionChange(CTelnetOption *pOption)
{

}

BOOL CTelnetOptionCollection::AgreeUsOn(CTelnetOption *pOption)
{
// 	if(pOption == &windowSizeOption)
// 	{
// 		//temp
// 		windowSizeOption.AnswerWindowSize(80, 24);
// 		
// 	}
	return TRUE;
}

BOOL CTelnetOptionCollection::AgreeHimOn(CTelnetOption *pOption)
{
	return TRUE;
}
